package com.chaosj.skill.grpc

import io.grpc.stub.StreamObserver
import static com.chaosj.skill.grpc.HelloWorldProtos.*
/**
 * @Description:
 * @author: caoyangjie
 * @date: 2019年12月2019/12/6日 15:23
 * @Copyright: © 赢时胜
 */
class MyGrpcService extends GreeterGrpc.GreeterImplBase {
    @Override
    void sayHello(HelloRequest request, StreamObserver<HelloReply> responseObserver) {
        HelloReply reply = null
        if( request.getMessage().contains("client") ){
            reply = HelloReply.newBuilder().setMessage("hello!this is server,who are you?").build()
        }else{
            reply = HelloReply.newBuilder().setMessage("什么乱七八糟的东西!").build()
        }
        responseObserver.onNext(reply)
        responseObserver.onCompleted()
    }
}
